#include "native/java/lang/Float.hpp"
//#include <bit>
#include <cstring>

namespace jvm {
    namespace lang {

        const std::string FloatNative::JL_FLOAT = "java/lang/Float";

        void FloatNative::floatToRawIntBits(std::shared_ptr<rtda::Frame> frame) {
            auto value = frame->getLocalVars().getFloat(0);
            uint32_t bits;
            std::memcpy(&bits, &value, sizeof(bits));
            frame->getOperandStack()->pushInt(static_cast<int32_t>(bits));
        }

        void FloatNative::intBitsToFloat(std::shared_ptr<rtda::Frame> frame) {
            auto bits = frame->getLocalVars().getInt(0);
            float value;
            std::memcpy(&value, &bits, sizeof(value));
            frame->getOperandStack()->pushFloat(value);
        }

    } // namespace lang
} // namespace jvm